{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "58504e50",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import IL Data\n",
    "import pandas as pd\n",
    "IL_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\IL_delegations.xlsx\")\n",
    "IL_delegations_dict = IL_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of content provisions by type\n",
    "il_delegations = 0\n",
    "il_provisions = 0\n",
    "il_man_provisions = 0\n",
    "il_per_provisions = 0\n",
    "il_con_provisions = 0\n",
    "\n",
    "for delegation in IL_delegations_dict:\n",
    "    il_delegations +=1\n",
    "    \n",
    "    if delegation['mandatory_content'] > 0:\n",
    "        il_man_provisions +=1\n",
    "    \n",
    "    if delegation['permissive_content'] > 0:\n",
    "        il_per_provisions +=1\n",
    "    \n",
    "    if delegation['constraining_content'] > 0:\n",
    "        il_con_provisions +=1\n",
    "\n",
    "il_provisions = il_man_provisions + il_per_provisions + il_con_provisions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "85eab6f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "## import UK Data\n",
    "UK_delegations = pd.read_excel(\"C:\\\\Users\\\\Nir\\\\Dropbox\\\\Codification\\\\Law-Regulation Research\\\\Nir PhD\\\\paper 2\\\\Submission\\\\Second Submission\\\\\\\\UK_delegations.xlsx\")\n",
    "UK_delegations_dict = UK_delegations.to_dict(\"records\")\n",
    "\n",
    "#count the total number of content provisions by type\n",
    "uk_delegations = 0\n",
    "uk_provisions = 0\n",
    "uk_man_provisions = 0\n",
    "uk_per_provisions = 0\n",
    "uk_con_provisions = 0\n",
    "\n",
    "for delegation in UK_delegations_dict:\n",
    "    uk_delegations +=1\n",
    "    \n",
    "    if delegation['mandatory_content'] > 0:\n",
    "        uk_man_provisions +=1\n",
    "    \n",
    "    if delegation['permissive_content'] > 0:\n",
    "        uk_per_provisions +=1\n",
    "    \n",
    "    if delegation['constraining_content'] > 0:\n",
    "        uk_con_provisions +=1\n",
    "\n",
    "uk_provisions = uk_man_provisions + uk_per_provisions + uk_con_provisions\n",
    "    \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "2a47cc7e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "-------------------------  ---  ------------------  ------  ------------------\n",
      "Type of Content Provision  UK   UK_percentage       Israel  Israel_Percentage\n",
      "mandatory                  63   8.974358974358974   0       0.0\n",
      "permissive                 234  33.33333333333333   5       2.0408163265306123\n",
      "constraining               6    0.8547008547008548  0       0.0\n",
      "total                      303  43.162393162393165  5       2.0408163265306123\n",
      "-------------------------  ---  ------------------  ------  ------------------\n"
     ]
    }
   ],
   "source": [
    "#create table 4 using tabulate\n",
    "from tabulate import tabulate\n",
    "\n",
    "table = [['Type of Content Provision', 'UK', 'UK_percentage', 'Israel', 'Israel_Percentage'], \n",
    "         ['mandatory', uk_man_provisions, uk_man_provisions/uk_delegations*100, il_man_provisions, il_man_provisions/il_delegations*100],\n",
    "         ['permissive', uk_per_provisions, uk_per_provisions/uk_delegations*100, il_per_provisions, il_per_provisions/il_delegations*100],\n",
    "         ['constraining', uk_con_provisions, uk_con_provisions/uk_delegations*100, il_con_provisions, il_con_provisions/il_delegations*100],\n",
    "         ['total', uk_provisions, uk_provisions/uk_delegations*100, il_provisions, il_provisions/il_delegations*100]] \n",
    "\n",
    "print(tabulate(table))\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39074015",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
